package hibernate;

import negocio.beans.central.*;
import negocio.beans.oficinaventa.*;


import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;

public class HibernateUtil
{
    private static SessionFactory sessionFactory;
    
    public static SessionFactory getSessionFactory()
    {
        try
        {
        	if(sessionFactory == null)
    		{
        	
        	AnnotationConfiguration config = new AnnotationConfiguration();
        	 //---Oficina de Venta---------
        	config.addAnnotatedClass(Item.class);
        	config.addAnnotatedClass(Remito.class); 
        	
        	
        	config.addAnnotatedClass(Marca.class);
        	 
        	config.addAnnotatedClass(Cotizacion.class);
       	 	config.addAnnotatedClass(Factura.class);
        	
        	 config.addAnnotatedClass(Cliente.class);
        	           	 
        	 
        	 config.addAnnotatedClass(OficinaVenta.class);
        	 config.addAnnotatedClass(OrdenDePedido.class);
        	 config.addAnnotatedClass(OrdenDeCompra.class);
        	 config.addAnnotatedClass(Rodamiento.class);
        	 
        	 //--Casa central----------------        	 
        	 config.addAnnotatedClass(ListaPrecio.class);
        	 config.addAnnotatedClass(ItemListaPrecio.class);
        	 config.addAnnotatedClass(MovimientoStock.class);
        	 config.addAnnotatedClass(Proveedor.class);
        	 config.addAnnotatedClass(Stock.class);
        	 config.addAnnotatedClass(RemitoProveedor.class); 
        	 config.addAnnotatedClass(CondicionVenta.class);
        	 config.addAnnotatedClass(Ganancia.class);
             return sessionFactory = config.buildSessionFactory();
             
    		}else{
    		 return sessionFactory;
    		}
        }
        catch (Throwable ex)
        {
            System.err.println("Initial SessionFactory creation failed." + ex);
            throw new ExceptionInInitializerError(ex);
        }
    }
 
}
